const {
	app,
	pool,
	Result
} = require('./connect');

const login = require('./Routes/login');
const userinfo = require('./Routes/userinfo');
const usersinfo = require('./Routes/usersinfo');
const todolist = require('./Routes/todolist');

const homePost = require('./Routes/MyRoute/homePost');
const homeGet = require('./Routes/MyRoute/homeGet');
const homeDel = require('./Routes/MyRoute/homeDel');
const homeUp = require('./Routes/MyRoute/homeUp');
const homeUpimg = require('./Routes/MyRoute/homeUpimg');
const homeUpimg2 = require('./Routes/MyRoute/homeUpimg2');

app.all('*', (req, res, next) => {
	// 处理全局拦截
	// console.log(req, res)
	next();
})

app.get('/', (req, res) => {
	pool.getConnection((err, conn) => {
		res.send("<a href='./login'>登录</a>")
		conn.release();
	})
})

app.use('/login', login);
app.use('/userinfo', userinfo);
app.use('/usersinfo', usersinfo);
app.use('/todolist', todolist);

app.use('/api', homePost);
app.use('/api', homeGet);
app.use('/api', homeDel);
app.use('/api', homeUp);
app.use('/api', homeUpimg);
app.use('/api', homeUpimg2);


/* 监听端口 */
app.listen(3000, () => {
	console.log('——————————服务已启动——————————,3000接口');
})